package it.unibz.easytravel.travel;


import it.unibz.easytravel.R;
import it.unibz.easytravel.db.PersonalItemsDbAdapter;
import it.unibz.easytravel.itemlist.TabManager;
import it.unibz.easytravel.weather.WeatherForecast;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.Toast;

public class PlanningActivity extends Activity {

	

	private Activity activity;

	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.planning_activity_layout);	
	
		
		this.activity = this;

		Button button_item_list = (Button) findViewById(R.id.ManageItemList);
		button_item_list.setOnClickListener(mItemList);

		Button button_ItemsDelete = (Button) findViewById(R.id.ItemsDelete);
		button_ItemsDelete.setOnClickListener(mItemsClear);

		Button button_Weather = (Button) findViewById(R.id.Weather);
		button_Weather.setOnClickListener(mWeather);
	
	}


	
	private OnClickListener mWeather = new OnClickListener() {
		public void onClick(View v) {
			Intent intent = new Intent(PlanningActivity.this, WeatherForecast.class);
			startActivity(intent);
		}
	};
	private OnClickListener mItemsClear = new OnClickListener() {
		public void onClick(View v) {
			PersonalItemsDbAdapter mLocDb = new PersonalItemsDbAdapter(activity);
			mLocDb.open();
			mLocDb.delete();
			mLocDb.close();
			// SelectPersonalItemsDbAdapter db = new
			// SelectPersonalItemsDbAdapter(activity);
			// db.open();
			// db.delete();
			// db.close();

			Toast.makeText(getBaseContext(), "Items deleted",
					Toast.LENGTH_SHORT).show();
		}
	};



	private OnClickListener mItemList = new OnClickListener() {
		public void onClick(View v) {
			Intent intent = new Intent(PlanningActivity.this, TabManager.class);
			startActivity(intent);
		}
	};

	
}
